﻿using FTBS.Models.BLO;
using FTBS.Models.Entities.Concert;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace FTBS.Controllers
{
    public class CheckOutController : Controller
    {
        private ChairBLO _boChair = new ChairBLO();
        private CheckOutBLO _checkoutBLO = new CheckOutBLO();
        private ScheduleBLO _scheduleBLO = new ScheduleBLO();


        public ActionResult Index()
        {
            var searchSchedule = this.Session["SearchSchedule"] as SearchSchedule;
            return View(_boChair.LoadChairs(searchSchedule.RoomId));
        }

        /// <summary>
        /// Load payment
        /// </summary>
        /// <param name="listId"></param>
        /// <returns></returns>
        /// <author>Nguyen</author>
        /// <edit>VuongVT</edit>
        /// <reason>Add roomId of session</reason>
        public ActionResult Payment(string listId)
        {
            SearchSchedule searchSchedule = new SearchSchedule();
            searchSchedule = this.Session["SearchSchedule"] as SearchSchedule;
            //double totalPrice = 120.560;
            string[] strListChair = listId.Split(' ');
            //string note = "abc";
            int scheduleId = _scheduleBLO.GetScheduleId(searchSchedule.FilmId, searchSchedule.RoomId, searchSchedule.ShowTimeId, searchSchedule.TheaterId);

            //var resultBooking = _checkoutBO.BookingTicket(searchSchedule.User.UserName, totalPrice, strListChair.Count(), note, listId, scheduleId);
            ////If have any chair is booked. Return alert message
            //if (resultBooking == 2)
            //{
            //    TempData["AlertMessage"] = "Vé bạn chọn đã được đặt. Xin vui lòng chọn lại!";
            //    return PartialView("BookChair", _boChair.LoadChairs(searchSchedule.RoomId));
            //}
            //If guest, return a view with null Fullname, PhoneNumber and Email
            //If customer, return a view with value of Fullname, PhoneNumber and Email
            if (string.Empty.Equals(searchSchedule.User.UserName))
            {

                return PartialView("PaymentInfomation", searchSchedule);
            }
            else
            {
                //If customer, return a view with value of Fullname, PhoneNumber and Email
                return PartialView("PaymentInfomation", searchSchedule);
            }
        }
        public ActionResult PaymentInfo()
        {
            return View();

        }


    }
}
